/** FASSIT (Forms of Selective Attention in Intelligent Transportation Systems)
 * Computational Creativity and Digital Media
 * Cognitive and Media Systems Group
 * Centre for Informatics and Systems of the University of Coimbra (CISUC)
 *
 * Copyright (c) 2010-2013 University of Coimbra, Portugal
 * All rights reserved.
 */

package masterAgent.DBmanager;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;

import poi.Info.Location;
import poi.Info.POI;
import agent.Context.Goal;

/**
 * 
 * @author Hernani Costa
 * @version 0.1 date: 19/11/2012
 */
public class DBManager implements Serializable {
	private static final long serialVersionUID = 1L;
	private DBConnection dbConnection;

	/**
	 * Constructor
	 */
	public DBManager() {
		dbConnection = new DBConnection();
	}

	/**
	 * ------------------------------------------------------------------------
	 * Returns all the POIs within a radius
	 * ------------------------------------------------------------------------
	 * 
	 * @param userLocation
	 *            - current user location
	 * @param radius
	 *            - radius to search POIs
	 * @return an arrayList with all the POIs within the radius
	 */
	/*
	 * public ArrayList<POI> getPOIsNear(Location userLocation, int radius) {
	 * return dbConnection.getPOIsNearLocation(userLocation, radius); }
	 */

	/**
	 * ------------------------------------------------------------------------
	 * Returns all the POIs within a radius for a specific Goal
	 * ------------------------------------------------------------------------
	 * 
	 * @param userLocation
	 *            - current user location
	 * @param radius
	 *            - radius to search POIs
	 * @param goal
	 *            - Goal
	 * @return an arrayList with all the POIs within the radius
	 */
	public HashMap<Integer, POI> getPOIsNear(Location userLocation, int radius,
			String goal) {
		return dbConnection.getPOIsNearLocation(userLocation, radius, goal);
	}

	/**
	 * ------------------------------------------------------------------------
	 * Only for debug purpose
	 * ------------------------------------------------------------------------
	 */
	public static void main(String args[]) {
		DBConnection connector = new DBConnection();

		POI poi = connector.getPOI(1507669);
		DBManager manager = new DBManager();

		HashMap<Integer, POI> pois = manager.getPOIsNear(poi.getLocation(),
				200, new Goal().getCoffee());
		for (POI p : pois.values()) {
			System.out.println(p.to_String());

		}
	}

}// END AgentDBManager

